package com.baf.remote;
import com.baf.xbmcapi.XBMCInterface;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.util.Log;
import org.json.*;
import android.widget.* ;


public class RemoteActivity extends Activity {

	TextView voldisp;    
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button incvol = (Button) findViewById(R.id.inc_vol);
        incvol.setOnClickListener(volumeListener);
        Button decvol = (Button) findViewById(R.id.dec_vol);
        decvol.setOnClickListener(volumeListener);
        Button settings = (Button) findViewById(R.id.showsettings);
        settings.setOnClickListener(volumeListener);
        Button ordbog = (Button) findViewById(R.id.ordbog);
        ordbog.setOnClickListener(volumeListener);
	voldisp = (TextView) findViewById(R.id.show_vol);
//	XBMCInterface.setIpAddress("192.168.1.112");
//	XBMCInterface.setPort(9090);
        
        
       
        
    }
    
    private OnClickListener volumeListener = new OnClickListener() {
        public void onClick(View v) {
        	Log.v("ABCD", " inside the onclick method");
        	
        	if (v.getId()==R.id.inc_vol)
        	{
        		
        		try {
					XBMCInterface.increaseVolume(5);
					
			
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
        	
        	}
        	else if (v.getId()== R.id.dec_vol)
        	{

        		try {
					XBMCInterface.decreaseVolume(5);
			
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					
				}
        		
        	}
		else if (v.getId()== R.id.showsettings)
        	{

				launchSettings();
        	}
		
		else if (v.getId()== R.id.ordbog)
        	{

				launchDictionary();
        	}



		String vol="";
/*		try{
		vol = ""+ XBMCInterface.getVolume();
		} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					
				}
        		
		voldisp.setText(vol);*/
		v.invalidate();
		
          
        }
    };
	 protected void launchSettings() {
        	Intent i = new Intent(this, SettingsActivity.class);
	        startActivity(i);
    	}	
	 protected void launchDictionary() {
        	Intent i = new Intent(this, DictionaryActivity.class);
	        startActivity(i);
    	}

}

